DOORS DXL - Comparing In-links with enumerated attributes

Hi there,

I'm relatively new with using DXL. Can anyone please help or suggest a solution (in DXL) for the problem below?

I have an enumerated attribute that suggest where an object should link to i.e. Module A, Module B, Module C etc and I am wanting to compare the values set in this attribute with the actual links into the object.
Thanks,
John
jmcgown - Mon Dec 14 09:45:56 EST 2009

Re: DOORS DXL - Comparing In-links with enumerated attributes
ManuelFelger - Mon Dec 14 09:49:25 EST 2009

Hey John,

I think this code snipped could help you:
 

Module m = current 
 
Object o = object(62)
 
string attribute
string srcModName = ""
 
LinkRef lref
 
for lref in o <- "*" do 
{
    srcModName = fullName source (lref)
                                
}
                        
attribute = o."Attribute Name"
 
print "srcModName: " srcModName "\n"
print "attribute: "  attribute  "\n"
 
if (srcModName == attribute)
{
        // do something here
}

 


Regards,
Manuel

 

Re: DOORS DXL - Comparing In-links with enumerated attributes
llandale - Mon Dec 14 17:37:03 EST 2009

This may help. Lets assume your enumerated values are the base name of the Allocated-to modules.

string Allocated = obj."Allocated"
Skip  skpAllocated = createString()
 
string Value, NameMod
Link   lnk
          // Get list of all allocated modules.  They are separated by EOls
bool  Done = false
int   Length = length(Allocated)
int   PosNew = -1
int   PosOld = -1
while(!Done)
{  PosNew++
   if (Allocated[PosNew] == '\n')
   {    // Found another entry
      if (PosOld >= Length) Done = true
      elseif (PosOld+1 == PosNew){}   // empty string, do nothing
      else
      {  Value = Allocated[PosOld+1:PosNew-1]
         put(skpAllocated, Value, Value)
      }
      PosOld = PosNew
   }
}
      // Get the last value, if any
if (PosOld+1 == PosNew){} // EmptString, do nothing
else
{  Value = Allocated[PosOld+1:]   // rest of the string
   put(skpAllocated, Value, Value)
}
//  OK, now we have a Skip list of selected values
 
for lnk in obj <- "*" do
{  NameMod = name(target(lnk))
   if (find(skpAllocated, NameMod))
   {  // Incoming link from a module to which we allocated
      delete(skpAllocated, Value)  // perhaps delete the value from the Skip
   }
   else
   {  // Incoming link from a module we did not allocate, or a 2nd such link
   }
}
for Value in skpAllocated do
{  report Value is allocated, but has no incoming link
}
delete(skpAllocated)

 

 

  • Louie

 

 

Re: DOORS DXL - Comparing In-links with enumerated attributes
jmcgown - Tue Dec 15 08:50:35 EST 2009

ManuelFelger - Mon Dec 14 09:49:25 EST 2009

Hey John,

I think this code snipped could help you:
 

Module m = current 
 
Object o = object(62)
 
string attribute
string srcModName = ""
 
LinkRef lref
 
for lref in o <- "*" do 
{
    srcModName = fullName source (lref)
                                
}
                        
attribute = o."Attribute Name"
 
print "srcModName: " srcModName "\n"
print "attribute: "  attribute  "\n"
 
if (srcModName == attribute)
{
        // do something here
}

 


Regards,
Manuel

 

Hi,

Thanks for the help. The only problem is that I think this code may be good for only one source module. But I have over 30 source modules (all located in one folder incidentally).

Does the (string srcModName = "") part mean any source module or am I supposed to name a single module in the quotes?
Is it possible to put a folder path in here or wildcard?

The code above, matches a non named enumerated attribute value (i.e. blank) with an object that doesnt have any links, which makes sense since there is nothing in the quotes above.
BTW, thanks for the speedy responses.

Re: DOORS DXL - Comparing In-links with enumerated attributes
jmcgown - Tue Dec 15 08:56:41 EST 2009

jmcgown - Tue Dec 15 08:50:35 EST 2009
Hi,

Thanks for the help. The only problem is that I think this code may be good for only one source module. But I have over 30 source modules (all located in one folder incidentally).

Does the (string srcModName = "") part mean any source module or am I supposed to name a single module in the quotes?
Is it possible to put a folder path in here or wildcard?

The code above, matches a non named enumerated attribute value (i.e. blank) with an object that doesnt have any links, which makes sense since there is nothing in the quotes above.
BTW, thanks for the speedy responses.

I forgot to mention. Once I do have the code working I will be displaying the total number of objects that match.
i.e. if all enumerated attribute values in an object have at least one link to the specified module.
Thanks,
John

Re: DOORS DXL - Comparing In-links with enumerated attributes
llandale - Tue Dec 15 11:56:55 EST 2009

jmcgown - Tue Dec 15 08:50:35 EST 2009
Hi,

Thanks for the help. The only problem is that I think this code may be good for only one source module. But I have over 30 source modules (all located in one folder incidentally).

Does the (string srcModName = "") part mean any source module or am I supposed to name a single module in the quotes?
Is it possible to put a folder path in here or wildcard?

The code above, matches a non named enumerated attribute value (i.e. blank) with an object that doesnt have any links, which makes sense since there is nothing in the quotes above.
BTW, thanks for the speedy responses.

No, he's just initializing the variable to null. That's good practice, and in this case its needed since its possible the loop finds nothing and you want the name to be null when the loop is exited.

The "*" part of the link loop means "any link module", which means the link finds the links. Once he has a link he gets the source module name. He should print it inside the loop, not outside.

If you want to restrict found links to a specific source module, perhaps basname "abc", then you get the name(source(link)) and continue if its not "abc".

  • Louie